package com.entrogy.dao;


import com.entrogy.bean.ArrangeEntity;
import com.entrogy.bean.ArrangeInformationEntity;
import com.entrogy.bean.DayTypeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AttendanceDao {
    @Select("SELECT * FROM arrange_information WHERE arrange_time=#{arrangeDate}")
    ArrangeInformationEntity getArrangeInfor(@Param("arrangeDate") String arrangeDate);

    @Select("SELECT * FROM  ${tableName} where school_code = #{schoolCode}")
    List<ArrangeEntity> getDynArrangeBeanList(@Param("tableName") String tableName,@Param("schoolCode") int schoolCode);

    @Select("SELECT * FROM day_type WHERE day_id=#{dayId}")
    DayTypeEntity getDayTypeBeanById(int dayId);

    @Select("SELECT * FROM static_arrange WHERE course_id=#{courseId} AND school_code = #{schoolCode} ORDER BY day_id")
    List<ArrangeEntity> getStaticArrangeBeanList(@Param("courseId") int courseId,@Param("schoolCode") int schoolCode);

    @Update("UPDATE ${tableName}  SET day_id = #{dayId},afternoon = #{timeSlot1}, evening = #{timeSlot2},night = #{timeSlot3} WHERE school_code = #{schoolCode} and course_id = #{courseId}")
    int setDynArrange(@Param("tableName") String tableName,@Param("dayId") int dayId, @Param("timeSlot1") String time_slot1, @Param("timeSlot2") String time_slot2,@Param("timeSlot3") String time_slot3,@Param("courseId") String course_id,@Param("schoolCode") int schoolCode);

    @Select("select * from static_arrange where school_code = #{schoolCode}")
    List<ArrangeEntity> getArrangeInfoBySCode(@Param("schoolCode") int schoolCode);
}
